<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<% 
  String username=(String) session.getAttribute("UserName");
	  if(username == null)
	  	username = "";
	  if(username.compareTo("admin") == 0 || username.compareTo("tien") == 0 )
	  {
		  //response.sendRedirect("index.jsp");
	  }
	  else
		  response.sendRedirect("ShowNotice2.jsp");
%>

<tiles:insertTemplate template="Template.jsp">

	<tiles:putAttribute name="head">
		<h1>Manager</h1>
	</tiles:putAttribute>
	
	<tiles:putAttribute name="body">
		
		<h3 style="text-align: center; color: red;">${errors}</h3>
<form id="frmprogory" name="frmprogory" method="post" action="ProductCRUD.do">
  <table cellpadding="4px" cellspacing="4px" bgcolor="#F4F5F7" width="500px" class="tableBorder"
        align="center">
        <tr>
            <td colspan="2" bgcolor="#0071bd" align="center">
                <span class="message">MANAGER PRODUCTS</span>
            </td>
        </tr> 
    <tr>
      <td class="label" align="left" style="font-weight: bold">Product Id</td>
      <td><input readonly type="text" class="box" name="txtId" value="${pro.Id}"/></td>
    </tr>
    <tr>
      <td class="label" align="left" style="font-weight: bold">Name</td>
      <td><input size="44" type="text" class="box" name="txtName" value="${pro.Name}" /></td>
    </tr>
    <tr>
      <td class="label" align="left" style="font-weight: bold">ProDuct Date</td>
      <td><input type="text" name="txtProDuctDate" class="box" value="${pro.ProDuctDate}" /></td>
    </tr>
       <tr>
      <td class="label" align="left" style="font-weight: bold">Picture</td>
      <td><input type="text" name="txtPicture" class="box" value="${pro.Picture}" /></td>
    </tr>
        <tr>
      <td class="label" align="left" style="font-weight: bold">Discount</td>
      <td><input type="text" name="txtDiscount" class="box" value="${pro.Discount}" /></td>
    </tr>
        <tr>
      <td class="label" align="left" style="font-weight: bold">Quantity</td>
      <td><input type="text" name="txtQuantity" class="box" value="${pro.Quantity}" /></td>
    </tr>
       </tr>
        <tr>
      <td class="label" align="left" style="font-weight: bold">CategoryId</td>
      <td><input type="text" name="txtCategoryId" class="box" value="${pro.CategoryId}" /></td>
    </tr>
   
     <tr>
            <td class="label" align="left" style="font-weight: bold">
                Special :
            </td>
            <td align="left" >
               <input type="radio" name="rdoSpecial" class="box" value="true" ${c.Special?'checked':'' }/> &nbsp;Special &nbsp;
               <input type="radio" name="rdoSpecial" class="box" value="false" ${c.Special?'':'checked' }/> &nbsp;No Special  &nbsp;
            </td>
        </tr>
    <tr>
      <td align="center" colspan="2" class="">
                <input type="submit" name="btnInsert" style="height: 30px;width: 100px;" class="btn btn-small btn-warning btn-success" value="Insert">
                &nbsp;
                <input type="submit" name="btnUpdate" style="height: 30px;width: 100px;" class="btn btn-small btn-warning btn-primary" value="Update">
                &nbsp;
                <input type="submit" name="btnDelete" style="height: 30px;width: 100px;"  class="btn btn-small btn-warning btn-danger" value="Delete">
            </td>
    </tr>
  </table>
  </form>

  <table class="table table-bordered" style="width: 90%;margin: 0px auto;">
  <tr align="center">
              		<td align="center" colspan="7">
	              		<form class="form-search" action="ProductCRUD.do" method="post">
	    					<input type="text" name="txtSearch" class="input-medium search-query">
	    					<input type="submit" name="btnSearch" class="btn" value="Search">
	    				</form>
              		</td>
              	</tr>
    <tr bgcolor="lightgray">
      <th>Id</th>
      <th>Name</th>
      <th>ProductDate</th>
      <th>Picture</th>
      <th>Discount</th>
      <th>Quantity</th>
      <th>CategoryId</th>
      <th>Special</th>
      <th>&nbsp;</th>
    </tr>
    <c:forEach var="c" items="${prod.rows}">
    <tr>
      <td>${c.Id}</td>
      <td>${c.Name}</td>
      <td>${c.ProductDate}</td>
      <td>${c.Picture}</td>
      <td>${c.Discount}</td>
      <td>${c.Quantity}</td>
      <td>${c.CategoryId}</td>
      <td>${c.Special}</td>
      <td><a href="?lnkEdit&txtId=${c.Id}">Edit</a></td>
    </tr>
    </c:forEach>
    </table>
</form>	
		
		
		
	</tiles:putAttribute>
	
</tiles:insertTemplate>